package AAA.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class fz {

        private static SqlSessionFactory sqlSessionFactory;

        /**
         * 类加载时初始化sqlSessionFactory对象
         */
        static {
            try {
                SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
                sqlSessionFactory = sqlSessionFactoryBuilder.build(Resources.getResourceAsStream("mybatis-config.xml"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }



        public static SqlSession openSession() {
            return sqlSessionFactory.openSession(true);
        }
    }

